package com.example.testdesign;

import android.content.Intent;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SwitchCompat;
import android.view.View;
import android.widget.EditText;

import butterknife.Bind;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {

    @Bind(R.id.edit_text)
    EditText editText;
    @Bind(R.id.text_input)
    TextInputLayout textInput;
    @Bind(R.id.root)
    ConstraintLayout root;
    @Bind(R.id.switch_com)
    SwitchCompat switchCom;
    @Bind(R.id.float_btn)
    FloatingActionButton floatBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        //SwitchCompat被竖线隔开
        switchCom.setSplitTrack(false);

//SwitchCompat右边会出现错误提示
        switchCom.setError("error");

//是否显示文字[默认为 开启/关闭](当然也可以自定义文字)
        switchCom.setShowText(true);

//自定义文字
        switchCom.setTextOff("Off");
        switchCom.setTextOn("On");

//设置左边文字和右边按钮的距离
        switchCom.setSwitchPadding(20);

//设置关闭和开启
        switchCom.setChecked(true);

        floatBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this,TwoActivity.class));
            }
        });

//监听switchCompat开启和关闭变化
//        switchCom.setOnCheckedChangeListener();

////设置Track图标
//        switchCom.setTrackResource(R.mipmap.ic_launcher);
//
////switchCompat设置指示图标[但是开启和关闭都是一个图标,可以在setOnCheckedChangeListener里动态设置]
//        switchCom.setThumbResource(R.mipmap.ic_launcher);
    }
}
